package com.bwie.parkdemo.mvvm.ui.activity;

import com.bwie.lib_core.mvvm.base.BaseActivity;
import com.bwie.parkdemo.BR;
import com.bwie.parkdemo.R;
import com.bwie.parkdemo.databinding.ActivityPatrolBinding;
import com.bwie.parkdemo.mvvm.viewmodel.AddPatrolViewModel;
import com.bwie.parkdemo.widget.dialog.AddPointDialog;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * 添加巡更路线界面
 * */
public class AddPatrolActivity extends BaseActivity<ActivityPatrolBinding,AddPatrolViewModel>
        implements AddPointDialog.AddPointDialogCallBack{

    @Override
    public int initLayout() {
        return R.layout.activity_patrol;
    }

    @Override
    public void initView() {
        EventBus.getDefault().register(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Override
    public int initVariable() {
        return BR.vm;
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void showPointDialog(String str){
        new AddPointDialog(this).setCallBack(this).show();
    }

    @Override
    public void addPointName(String name) {
        //dialog回掉回来的用户输入的点的内容
        vm.addPoint(name);
    }
}
